package com.lightkits.wms.domain.nontaskpickinglist;

import com.lightkits.framework.common.exception.LightKitsBizException;
import com.lightkits.framework.common.model.IResult;
import com.lightkits.framework.common.utility.object.ObjectUtil;
import com.lightkits.framework.soa.hzero.executor.ServiceExecutor;
import com.lightkits.wms.domain.nontaskpickinglist.service.CreateNonTaskPickDomain;
import com.lightkits.wms.dto.nontaskpicking.NonTaskPickingRequestType;
import com.lightkits.wms.dto.nontaskpicking.NonTaskPickingResponseType;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * NonTaskPickingExecutor
 *
 * @author jing.wei@hand-china.com
 * Created on 2019/5/9 14:36
 */
@Component
public class NonTaskPickingExecutor implements ServiceExecutor<NonTaskPickingRequestType,NonTaskPickingResponseType> {
 private final CreateNonTaskPickDomain domain;

    @Autowired
    public NonTaskPickingExecutor(CreateNonTaskPickDomain domain) {
        this.domain = domain;
    }

    @Override
    public NonTaskPickingResponseType service(NonTaskPickingRequestType request){
        NonTaskPickingResponseType response=new NonTaskPickingResponseType();
        response.setSuccessful(true);
            if(ObjectUtil.isEmpty(request.getHeaderDTO())){
               response.setSuccessful(false);
               response.setMessage("the Header is empty");
               return response;
            }
            IResult result = domain.insertValue(request.getHeaderDTO(),request.getLineDTOList());
            if (result.isSuccessful()) {
                return result.fill(response);
            }
            result.fill(response);

        return response;
    }
}
